package cn.net.xyan.easy.webapp.base;

import cn.net.xyan.easy.spring.core.config.AbstractAutoConfig;
import cn.net.xyan.easy.spring.core.config.value.ConfigKey;
import cn.net.xyan.easy.spring.core.utils.JsonHelper;
import cn.net.xyan.easy.webapp.base.config.MVCConfig;
import cn.net.xyan.easy.webapp.base.config.RootConfig;
import cn.net.xyan.easy.webapp.base.config.SecurityConfig;
import cn.net.xyan.easy.webapp.base.service.impl.DefaultSystemConfigService;
import cn.net.xyan.easy.webapp.base.service.impl.DefaultWebModuleService;
import cn.net.xyan.easy.webapp.base.service.impl.JPASecurityService;

import java.util.Collections;

import static cn.net.xyan.easy.spring.core.config.AbstractAutoConfig.ApplicationContextEnum.*;
/**
 * Created by xiashenpin on 16/1/17.
 */
public class WebAppBase extends AbstractAutoConfig{

    public static final ConfigKey StatusTypeScanPackages = new ConfigKey("StatusTypeScanPackages","", JsonHelper.StringSet, Collections.emptySet());

    public static final ConfigKey SystemConfigServiceImplClass = new ConfigKey("SystemConfigServiceImplClass","", JsonHelper.javaType(Class.class), DefaultSystemConfigService.class);

    public static final ConfigKey SecurityServiceImplClass = new ConfigKey("SecurityServiceImplClass","", JsonHelper.javaType(Class.class), JPASecurityService.class);

    public static final ConfigKey WebModuleServiceImplClass = new ConfigKey("WebModuleServiceImplClass","", JsonHelper.javaType(Class.class), DefaultWebModuleService.class);

    public static final String DefaultTheme = "DefaultTheme";

    @Override
    protected void configManager() {

        setupKey(SystemConfigServiceImplClass);

        setupKey(SecurityServiceImplClass);

        setupKey(WebModuleServiceImplClass);

        setupKey(StatusTypeScanPackages).enableValue(packageName("entity"));

        registerApplicationConfigClass(ROOT,RootConfig.class);
        registerApplicationConfigClass(ROOT,SecurityConfig.class);
        registerApplicationConfigClass(MVC,MVCConfig.class);

        registerRepositoryPackage(packageName("dao"));
        registerEntityPackage(packageName("entity"));

    }

    @Override
    protected void afterConfigManager() {

    }

}
